package com.pavco.caribbeanvisit.client.event;

import java.util.ArrayList;

import com.google.gwt.event.shared.GwtEvent;
import com.pavco.caribbeanvisit.client.eventhandlers.ReceivedSearchResultsEventHandler;
import com.pavco.caribbeanvisit.shared.models.Attraction;

public class ReceivedSearchResultsEvent extends GwtEvent<ReceivedSearchResultsEventHandler> {
  
  public static final GwtEvent.Type<ReceivedSearchResultsEventHandler> TYPE =
    new GwtEvent.Type<ReceivedSearchResultsEventHandler>();
  
  private Throwable caught;
  ArrayList<Attraction> results;

  @Override
  protected void dispatch(ReceivedSearchResultsEventHandler handler) {
    handler.onReceived(this);
  }

  @Override
  public GwtEvent.Type<ReceivedSearchResultsEventHandler> getAssociatedType() {
    return TYPE;
  }
  
  public boolean isFailed() {
    return (caught != null);
  }
  
  public void setError(Throwable caught) {
    this.setError(caught);
  }

  public Throwable getError() {
    return caught;
  }

  public ArrayList<Attraction> getResults() {
    return results;
  }

  public void setResults(ArrayList<Attraction> results) {
    this.results = results;
  }
}